﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace SHOOTER.Managers
{
    class MouseManager
    {
        private static MouseManager sInstance;

        //private MouseState mCurrentMouseState = Mouse.GetState();
        //private MouseState mPreviousMouseState;
        private MouseState mMouseState;
        public MouseState MouseState { get { return mMouseState; } set { mMouseState = value; } }
        private MouseState mPrevMouseState;

        private MouseManager()
        {
            //Vector2 mousePosition;
            //mousePosition.X = mCurrentMouseState.X;
            //mousePosition.Y = mCurrentMouseState.Y;
            mMouseState = Mouse.GetState();
        }

        //if (mCurrentMouseState.LeftButton == ButtonState.Pressed)
        //{

        //}

        //if (mCurrentMouseState.LeftButton == ButtonState.Pressed && mPreviousMouseState.LeftButton != ButtonState.Pressed)
        //{

        //}
        public static MouseManager Instance
        {
            get
            {
                if (sInstance == null)
                {
                    sInstance = new MouseManager();
                }
                return sInstance;
            }
        }


        public void Update(GameTime gameTime)
        {

            //mPreviousMouseState = mCurrentMouseState;
            mMouseState = Mouse.GetState();
            mPrevMouseState = mMouseState;
        }
    }
}

//        public bool LMouseButtonPressed(){
//            //returns true if is 1st button press
//            bool retVal = false;
//            {
//                if (mMouseState.LeftButton == ButtonState.Pressed && mPrevMouseState.LeftButton == ButtonState.Released){
//                    retVal = true;
//                    Console.WriteLine("Left Button Pressed");
//                }
//                return retVal;
//            }
//        }

//        public bool LMouseButtonReleased()
//        {
//            bool retVal = false;
//            {
//                if (mMouseState.LeftButton == ButtonState.Released && mPrevMouseState.LeftButton == ButtonState.Pressed)
//                {
//                    retVal = true;
//                    Console.WriteLine("LeftButton Released");
//                }
//                return retVal;
//            }
//        }

//        public bool RMouseButtonPressed()
//        {

//            bool retVal = false;
//            {
//                if (mMouseState.RightButton == ButtonState.Pressed && mPrevMouseState.RightButton == ButtonState.Released)
//                {
//                    retVal = true;
//                    Console.WriteLine("Right Button Pressed");
//                }
//                return retVal;
//            }
//        }

//        public bool RMouseButtonReleased()
//        {
//            bool retVal = false;
//            {
//                if (mMouseState.RightButton == ButtonState.Released && mPrevMouseState.RightButton == ButtonState.Pressed)
//                {
//                    retVal = true;
//                    Console.WriteLine("Right button Released");
//                }
//                return retVal;
//            }
//        }

//        public Vector2 MouseMovement()
//        {

//            return new Vector2(mMouseState.X - mPrevMouseState.X, mMouseState.Y - mPrevMouseState.Y);
//        }
//    }
//}
